package Demo4.mapper;

import Demo4.bean.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {
    //查全部学生
    //select s.id,s.name,s.age from student s,stu_cr sc where s.id=sc.sid
    @Select(" select distinct s.id,s.name,s.age from student s,stu_cr sc where s.id=sc.sid")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),
            @Result(
                  property = "courses",
                    javaType = List.class,
                    column = "id",
                 many = @Many(select = "Demo4.mapper.CourseMapper.selectByIdSid")
            )
    })
    List<Student> selectAll();
}
